package com.sskj.mine.presenter;

import android.view.View;

import com.lzy.okgo.model.Response;
import com.sskj.common.base.HttpData;
import com.sskj.common.util.ToastUtil;
import com.sskj.lib.http.JsonCallBack;
import com.sskj.mine.bean.LockHouseBean;
import com.sskj.mine.http.HttpConfig;
import com.sskj.mine.ui.activity.LockWareHouseActivity;

/**
 * Created by QinKang on 2018/12/15.
 */

public class LockWareHousePresent extends BasePresenter<LockWareHouseActivity> {


    public void getLockHouseType(String pid) {
        httpService.getLockHouseType(pid)
                .execute(new JsonCallBack<HttpData<LockHouseBean>>(this) {
                    @Override
                    public void onSuccess(Response<HttpData<LockHouseBean>> response) {
                        HttpData<LockHouseBean> httpData = response.body();
                        if (httpData.getStatus() == HttpConfig.OK) {
                            mView.setLockTypies(httpData.getData());
                        } else {
                            ToastUtil.showShort(httpData.getMsg());
                        }
                    }
                });
    }

    public void commitLockHouse(String id, String num, String tpwd) {
        httpService.commitLockHouse(id, num, tpwd)
                .execute(new JsonCallBack<HttpData>(this) {
                    @Override
                    public void onSuccess(Response<HttpData> response) {
                        HttpData<LockHouseBean> httpData = response.body();
                        ToastUtil.showShort(httpData.getMsg());
                        if (httpData.getStatus() == HttpConfig.OK) {
                            mView.finish();
                        }
                    }
                });
    }


}
